package com.kuaidi100.sdk.utils;

import com.google.gson.Gson;
import com.kuaidi100.sdk.api.QueryTrack;
import com.kuaidi100.sdk.contant.CompanyConstant;
import com.kuaidi100.sdk.core.IBaseClient;
import com.kuaidi100.sdk.pojo.HttpResult;
import com.kuaidi100.sdk.request.QueryTrackParam;
import com.kuaidi100.sdk.request.QueryTrackReq;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 1.描述（@desc）：快递信息的工具类
 * 2.作者（@author）：夏亮辉
 * 3.日期（@date）：2021年06月24  17:20
 * 4.版本（@version）：1.0.0
 * 5.版权：
 */

public class ExpressInfoUtil {


    private static  String key = PropertiesReader.get("key");
    private static  String customer = PropertiesReader.get("customer");
    private static  String secret = PropertiesReader.get("secret");
    private static  String siid = PropertiesReader.get("siid");
    private static  String userid = PropertiesReader.get("userid");
    private static  String tid = PropertiesReader.get("tid");
    private static  String secret_key = PropertiesReader.get("secret_key");
    private static  String secret_secret = PropertiesReader.get("secret_secret");


    /**
     * 根据 信息 查询 快递 轨迹信息
     * @param abbr  快递公司缩写
     * @param phone 收件人电话
     * @param number 快递单号
     * @return
     */
    public static HttpResult getExpressInfo(String abbr, String phone, String number){
        QueryTrackReq queryTrackReq = new QueryTrackReq();
        QueryTrackParam queryTrackParam = new QueryTrackParam();
        queryTrackParam.setCom(abbr);
        queryTrackParam.setNum(number);
        queryTrackParam.setPhone(phone);
        String param = new Gson().toJson(queryTrackParam);
        queryTrackReq.setParam(param);
        queryTrackReq.setCustomer(customer);
        queryTrackReq.setSign(SignUtils.querySign(param ,key,customer));
        IBaseClient baseClient = new QueryTrack();
        try {
            return baseClient.execute(queryTrackReq);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


}
